/**
 * Created by Dalyn on 2017/3/14.
 */
import React , {Component}from 'react';
import {Modal,Icon} from 'antd';
import "./css/materielBom.css"

export default class BatchHint extends React.Component {
    constructor(props){
        super(props);
        this.state = {
            visible:false,
            text:"",
            hintType:"",
            operateType:"",
        };
        this.deleteflag =false;
        this.hintType="";
        this.operateType="";
    }

    showConfirmModal(flag,params) {
        this.setState({
            visible:flag,
            text:params.message?params.message:"提示",
            hintType:params.hintType?params.hintType:"warning",
            operateType:params.operateType?params.operateType:null,
        });
    }

    onSure(){
        let {operateType} = this.state;
        this.setState({
            visible:false
        });
        if(operateType){
            this.props._clickConfirm(operateType);
        }
    }
    handleCancel = () => {
        this.setState({
            visible: false,
        });
    };
    iconType(){
        switch (this.hintType){
            case "warning":
                return(
                    <Icon type="exclamation-circle"  className="materielBom_warning" style={{color:"#fc880c"}}/>
                );
                break;
            default:
                return(
                    <Icon type="exclamation-circle"  className="materielBom_warning" style={{color:"#fc880c"}}/>
                );
                break;
        }
    }
    render(){
        return (
            <Modal className="batchhint_modal"
                   title="提示"
                   visible={this.state.visible}
                   onCancel={this.handleCancel}
                   onOk={this.onSure.bind(this)}
            >
                <p className="materielBom_hint_text">
                    {
                        this.iconType()
                    }
                    <span className="materielBom_hint_word">{this.state.text}</span>
                </p>
            </Modal>
        )
    }
}